﻿<UserControl x:Class="F5.BigIp.LocalTrafficManager.UI.Views.PoolControl"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:local="clr-namespace:F5.BigIp.LocalTrafficManager.UI.ViewModels"
             xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
             mc:Ignorable="d" 
             d:DesignHeight="300" 
             d:DesignWidth="300">

    <UserControl.DataContext>
        <local:MainViewModel />
    </UserControl.DataContext>

    <Grid>
        <DataGrid x:Name="DataGrid" 
                  ItemsSource="{Binding Pools}" 
                  SelectionMode="Single"
                  IsReadOnly="True" 
                  AutoGenerateColumns="False"
                  SelectedItem="{Binding SelectedPool}"
                  RowHeaderWidth="0" VerticalScrollBarVisibility="Visible">

            <i:Interaction.Triggers>
                <i:EventTrigger EventName="SelectionChanged">
                    <i:InvokeCommandAction Command="{Binding LoadPoolMembersCommand}" CommandParameter="{Binding SelectedPool}"/>
                </i:EventTrigger>
            </i:Interaction.Triggers>

            <DataGrid.Resources>

                <SolidColorBrush x:Key="{x:Static SystemColors.ControlBrushKey}" Color="{x:Static SystemColors.InactiveCaptionColor}"/>
                
                <Style TargetType="DataGridCell" BasedOn="{StaticResource {x:Type DataGridCell}}">
                    <Setter Property="Height" Value="32" />
                    <Setter Property="Template">
                        <Setter.Value>
                            <ControlTemplate TargetType="{x:Type DataGridCell}">
                                <Grid Background="{TemplateBinding Background}">
                                    <ContentPresenter HorizontalAlignment="Left" VerticalAlignment="Center" Margin="5,0,5,0"/>
                                </Grid>
                            </ControlTemplate>
                        </Setter.Value>
                    </Setter>
                </Style>

                <Style x:Key="StatusCellStyle" TargetType="DataGridCell" BasedOn="{StaticResource {x:Type DataGridCell}}">
                    <Style.Triggers>
                        <DataTrigger Binding="{Binding Path=Status}" Value="Disabled">
                            <Setter Property="Foreground" Value="DarkRed"/>
                            <Setter Property="FontWeight" Value="Bold"/>
                            <Setter Property="ToolTip" Value="Disabled"/>
                        </DataTrigger>
                    </Style.Triggers>
                </Style>
                
            </DataGrid.Resources>

            <DataGrid.Columns>
                <DataGridTextColumn Header="Pool" MinWidth="160" Binding="{Binding Name}" CellStyle="{StaticResource StatusCellStyle}"/>
            </DataGrid.Columns>
        </DataGrid>
    </Grid>
</UserControl>
